<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>理想视口的优点</title>
    <!-- 如果没有理想视口的开启，那么色块显示是部分 -->
    <meta name="viewport" content="width=device-width" />

    <style>
        * {
            margin: 0;
            padding: 0
        }

        #demo {
            background: skyblue;
            width: 375px;
            height: 200px;
        }
    </style>
</head>

<body>
    <div id="demo"></div>
    <script>
        console.log('该设备的布局视口宽度：', document.documentElement.clientWidth);
        console.log('该设备的视觉视口宽度：', window.innerWidth);
        const demo = document.getElementById('demo');
        demo.innerHTML = '布局视口宽度：' + document.documentElement.clientWidth;
        demo.innerHTML += '视觉视口宽度：' + window.innerWidth;
    </script>
</body>

</html>